/**
 * Created by abiu on 2016-05-09.
 */
baseUrl = "http://114.55.33.88:8080/virtualStock";
//baseUrl = "http://127.0.0.1:2111";


var listTransferOrder = getApi('/transferOrder/list'),
    modifyTransferOrder = getApi('/transferOrder/modify'),
    createTransferOrder = getApi('/transferOrder/create'),
    removeTransferOrder = getApi('/transferOrder/delete', {code: 0, result: {n: 1}});
function newTransferOrder(ob) {
    var id = getUniqueId();
    var origin = {
        "transferOrderNo": "调拨单号"+id,
        "expressNo": "20160420883929728",
        "expressCo": "顺丰快递",
        "channelIdFrom": initTransferOrder.channelId ,
        "channelIdTo": "JK3214415",
        "addressTo": "广州市白云区机场路888号",
        "contactPerson": "陈晨",
        "contactWay": "13543245676",
        "snList": {"sn01": {}, "sn02": {}},
        "memo": "备注"
    }

if (ob) {
    Object.keys(ob).forEach(function (key) {
        origin[key] = ob[key];
    })
}
return origin;
}
var initTransferOrder = {}

describe('init transferOrder ',function(){

})
describe("新增渠道 /transferOrder/create", function () {

    testNormally(newTransferOrder, '/transferOrder/create', '/transferOrder/list', '/transferOrder/delete');
    testRequire(newTransferOrder, ['transferOrderId', 'transferOrderName'], '/transferOrder/create', '/transferOrder/list', '/transferOrder/delete');
    testUnique(newTransferOrder, ['transferOrderId'], '/transferOrder/create', '/transferOrder/list', '/transferOrder/delete')


})

describe('修改渠道 /transferOrder/modify', function () {

})

describe('删除渠道 /transferOrder/delete', function () {
    var result;
    var transferOrder = newTransferOrder();
    createTransferOrder(function () {
        return transferOrder
    }, null, function (data) {
        result = data.result
    })
    removeTransferOrder(function () {
        return result
    })
    listTransferOrder(function () {
        return transferOrder
    }, {code: 0}, function (data) {
        expect(data.result.length).toBe(0)
    })

})